Modify Attribute_TypedParamsConstant_EnumArray_ConstructorArgument test to work on Mono#79955
Modify Attribute_TypedParamsConstant_EnumArray_ConstructorArgument test to work on Mono#79955jjonescz merged 5 commits intodotnet:mainfrom
Conversation
This is due to the difference in the way the constructorArguments are structured in Mono and CoreCLR which allows (IEnumerable)arg.Value).Cast<CustomAttributeTypedArgument>() to be done in CoreCLR but not on Mono. This throws a "System.InvalidCastException: Specified cast is not valid" on Mono.
There was a problem hiding this comment.
Consider instead changing the test so it works on Mono (this would also catch when the Mono behavior changes, e.g., if the runtime issue is fixed). I would keep the link to the runtime issue in a WorkItem attribute on this test though.
The Console.WriteLine line in the test could be conditional and this alternative should work on Mono if my experiments are correct:
Console.WriteLine(((IEnumerable)arg.Value).Cast<object>().SingleOrDefault() ?? "null");There was a problem hiding this comment.
Yep! Thank you! I have accommodated the changes.
There was a problem hiding this comment.
Btw, your PR description says "closes: dotnet/runtime#118568" which would close the runtime issue when this PR is merged. Is that intended? That way the issue might not get triaged.
There was a problem hiding this comment.
I'm sorry. That wasn't intended. I have removed it from the description.
|
Thanks @Venkad000 |
Modify Attribute_TypedParamsConstant_EnumArray_ConstructorArgument test to work on Mono. The test fails with a System.InvalidCastExpception due to the difference in the way the constructorArguments are structured in Mono and CoreCLR which allows (IEnumerable)arg.Value).Cast() to be done in CoreCLR but not on Mono.